home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Info-Mac 4
/
Info_Mac IV CD-ROM (Pacific HiTech Inc.)(August 1994).iso
/
Development
/
Source
/
DBL Pascal Library
/
Misc
/
SubmenuDelay
< prev
Wrap
Text File
|
1991-05-10
|
3KB
|
64 lines
unit SubmenuDelay;
interface
{These routines are handy for slowing down submenus when they're _really_ wide (> half screen)}
{You should call IncreaseSubmenuDelay just before a call to PopUpMenuSelect when you know that}
{the submenus may be wider than half of the screen width, and RestoreSubmenuDelay right after}
{returning from PopUpMenuSelect.}
{}
{The submenu delay is how long an item must be selected before its submenu pops up. When a submenu}
{is wider than half of the screen width, the menu manager has no choice but to pop it up right under the}
{pointer. With the default delay (8 ticks), it's tough to get out of the submenu and down to the next item}
{in the main menu. IncreaseSubmenuDelay records the original submenu delay and stretches this time out}
{to 20 ticks (see newDelay). RestoreSubmenuDelay puts the delay back to its original setting.}
procedure IncreaseSubmenuDelay;
procedure RestoreSubmenuDelay;
implementation
var
savedMenuDelay: SignedByte;
const
MBSaveLoc = $B5C; {global at this address contains a handle to some menu info}
mbMenuDelay = $E; {this offset in the handle holds the byte that controls the submenu delay}
newDelay = 20;
{ Pay attention now, I'm only going to tell you this once:}
{}
{ 1) MBSaveLoc is declared in the Private.a file which came with MPW. (I knew MPW was good for something.)}
{ 2) Handle(MBSaveLoc) says that we want to use the constant as a pointer to a pointer.}
{ 3) Handle(MBSaveLoc)^ gets the pointer I just mentioned, but…}
{ 4) …that pointer is actually a handle, so Handle(Handle(MBSaveLoc)^) set us up to…}
{ 5) …dereference the handle using Handle(Handle(MBSaveLoc)^)^, which gives us a pointer to the data.}
{ 6) Now, we add an offset to that pointer, using ORD(Handle(Handle(MBSaveLoc)^)^)+mbMenuDelay, and…}
{ 7) …coerce it to a byte pointer using Ptr(ORD(Handle(Handle(MBSaveLoc)^)^)+mbMenuDelay), which we save…}
{ 8) …in the delayPtr variable so we can use delayPtr^ to reference the one byte we really want.}
{}
{ Any questions?}
{}
{ Oh, yeah, one more thing: Since MBSaveLoc is declared in Private.a, we're not supposed to know about}
{ it, much less use it! If the submenus start behaving funny after some future rev of Apple's System SW,}
{ I'd look here first for the cause of the problem…}
procedure IncreaseSubmenuDelay;
var
delayPtr: Ptr;
begin
delayPtr := Ptr(ORD(Handle(Handle(MBSaveLoc)^)^) + mbMenuDelay);
savedMenuDelay := delayPtr^;
if savedMenuDelay < newDelay then
delayPtr^ := newDelay;
end;
{Sorry, but I'm not going to explain all this again!}
procedure RestoreSubmenuDelay;
var
delayPtr: Ptr;
begin
delayPtr := Ptr(ORD(Handle(Handle(MBSaveLoc)^)^) + mbMenuDelay);
delayPtr^ := savedMenuDelay;
end;
end.